package Day1;

import java.util.*;

public class Test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            if(str.isEmpty()){
                System.out.println(0);
                continue;
            }
            char[] ch = str.toCharArray();
            Stack<Character> stack = new Stack<>();
            stack.push(ch[0]);
            for(int i = 1;i < ch.length;i++){
                if(!stack.isEmpty()){
                    if(stack.peek() == ch[i]){
                        stack.pop();
                    }else {
                        stack.push(ch[i]);
                    }
                }else {
                    stack.push(ch[i]);
                }
            }
            if(stack.isEmpty()){
                System.out.println(0);
                continue;
            }
            int size = stack.size();//需要一个数记录栈的大小，防止之后发生变化
            Character[] newch = new Character[size];
            for (int i = 0; i < size; i++) {
                newch[i] = stack.pop();
            }
            for (int i = newch.length - 1; i >= 0 ; i--) {
                System.out.print(newch[i]);
            }
            System.out.println();
        }
    }
}